import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
const originalPush = Router.prototype.push
Router.prototype.push = function push(location, onResolve, onReject) {
    if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
    return originalPush.call(this, location).catch(err => err)
}


export default new Router({
  routes: [
    {
      path: '/',
      name: '微信',
      components: {
        default:resolve => require(['@/components/pages/index'], resolve),
        navBar:resolve => require(['@/components/Nav_bottom'], resolve),
        topBar:resolve => require(['@/components/topBar'], resolve),
      }
    },
    {
      path: '/MailList',
      name: '通讯录',
      components: {
        default:resolve => require(['@/components/pages/MailList'], resolve),
        navBar:resolve => require(['@/components/Nav_bottom'], resolve),
        topBar:resolve => require(['@/components/topBar'], resolve),
      }
    },
    {
      path: '/Find',
      name: '发现',
      components: {
        default:resolve => require(['@/components/pages/Find'], resolve),
        navBar:resolve => require(['@/components/Nav_bottom'], resolve),
        topBar:resolve => require(['@/components/topBar'], resolve),
      }
    },
    {
      path: '/Me',
      name: '我',
      components: {
        default:resolve => require(['@/components/pages/Me'], resolve),
        navBar:resolve => require(['@/components/Nav_bottom'], resolve),       
      }
    },
    {
      path: '/msgbox',
      name: '聊天室',
      component: resolve => require(['@/components/pages/msgbox/msgbox'], resolve)
    },
    {
      path: '/setUser',
      name: '设置',
      component: resolve => require(['@/components/pages/userSet/userSet'], resolve), 
    }
  ]
})
